#ifndef __DDEventManager__
#define __DDEventManager__

#include <map>
#include <string>
#include "TObject.h"
#include "TCanvas.h"
#include "TEveManager.h"
#include "TEveElement.h"

#include "DDVData.hh"
#include "DDVAnalysis.hh"

// This is the GUIs interface to user data, analysis, and visualization
// Use the Register functions to load the classes.
// When the TSKGLEEveWindow is initialize, this class initializes the data.
//  It calls the virtual function TSKGLVData::Initialize() for each type of data
// When each event is loaded
//   GotoEvent is called which calls TSKGLVData::GetEvent(n) for each data class
//   RunAnalyses is called which calls TSKGLVVisualAnalysis::AnalyzeEvent for each analysis class
//   DisplayDigitData is called.g
// m_EventID keeps track of the number of the event ID processed.

class DDEventManager : public TObject {

public:
  
  DDEventManager();
  virtual ~DDEventManager();

  void RegisterDataClass( DDVData* data, std::string name );
  void RegisterAnalysisClass( DDVAnalysis* analysis, std::string name );
  void Initialize( TEveManager* eveMan );
  void TearDownData();
  void RunAnalyses();
//  void DisplayDigiData();

  void DisplayEvents();
  void DisplayAnalyses();

  void GetNextEvent();
  void GetPrevEvent();
  void GoToEvent(int n);
  DDVData* GetDataClass( std::string name ) { return loadedDataClasses[name]; };
  DDVAnalysis* GetAnalysisClass( std::string name ) { return loadedAnalysisClasses[name]; };
  TEveElement* GetDigiSet( std::string name ) { return loadedDigiSets[name]; }; // should go through analysis to get it
  void MakeEventNavGui(  TEveManager* eveMan );
  std::vector<std::string> AnalysesOrder;

  enum { kOK, kError, kEndOfFile };
  
private:
  
  // We abuse the stl containers to store our data and analysis classes.  
  // We register each with a name
  std::map<std::string, DDVAnalysis*> loadedAnalysisClasses;
  std::map<std::string, TEveElement*> loadedDigiSets; // This is the data to visualize.  We register with TEveManager.
  std::map<std::string, DDVData*> loadedDataClasses;
  std::map<std::string, TCanvas*> canvases;


  int m_EventID;
  TEveManager* m_eveManager;

  ClassDef( DDEventManager, 0 );

};

#endif
